#include <bits/stdc++.h>
#define File(xxx) freopen(xxx".in","r",stdin),freopen(xxx".out","w",stdout)
using namespace std;
typedef long long LL;
const int N = 3e5+5;
int n, q, l[N], r[N], opt, s, t, d, c, ans;

template <typename T> inline void debug(T x) { cerr<<x; }
template <typename T, typename ...T_> inline void debug(T x, T_ ...p) { cerr<<x<<' ', debug(p...); }
template <typename T> void read(T& x) {
	x = 0; int f = 0; char c = getchar();
	while(c < '0' || c > '9') f |= (c == '-'), c=getchar();
	while(c >= '0' && c <= '9') x=(x<<1)+(x<<3)+(c^48), c=getchar();
	x=(f ? -x : x);
}
int lne; char put[105];
template <typename T> void write(T x, char ch) {
	lne = 0; if(x < 0) putchar('-'), x=-x;
	do { put[++lne]=x%10, x/=10; } while(x);
	while(lne) putchar(put[lne--]^48);
	putchar(ch);
}

signed main() {
	File("study");
	read(n), read(q);
	for(int i = 1; i < n; ++i)
		read(l[i]), read(r[i]);
	for(int i = 1; i <= q; ++i) {
		read(opt);
		if(opt == 2) {
			read(s), read(c), read(t), read(d);
			ans=0;
			if(s < t) {
				for(int i = s; i < t; ++i)
					ans+=max(0, c-r[i]+1), c=(c >= r[i] ? r[i] : max(c+1, l[i]+1));
				ans+=max(0, c-d);
			}
			else {
				for(int i = s-1; i >= t; --i)
					ans+=max(0, c-r[i]+1), c=(c >= r[i] ? r[i] : max(c+1, l[i]+1));
				ans+=max(0, c-d);
			}
			write(ans, '\n');
		}
		else 
			read(s), read(l[s]), read(r[s]);
	}
	return 0;
}